﻿using Avalonia.Controls;
using Microsoft.Extensions.DependencyInjection;

namespace LS.Screening.UI.Common.Mvvm
{
    public class CommonApplication: Avalonia.Application
    {
        /// <summary>
        /// 当前Window
        /// </summary>
        public static Window CurrentWindow { get; private set; }

        /// <summary>
        /// 当前登录用户
        /// </summary>
        public static CurrentLoginUser CurrentLoginUser { get; private set; }

        /// <summary>
        /// 服务集合
        /// </summary>
        protected static IServiceCollection Services { get; set; }

        /// <summary>
        /// 容器
        /// </summary>
        protected static IServiceProvider ServiceProvider { get; set; }

        /// <summary>
        /// 获取服务
        /// </summary>
        public static T GetService<T>() => ServiceProvider.GetService<T>();

        /// <summary>
        /// 设置 当前窗体
        /// </summary>
        /// <param name="window"></param>
        public static void SetCurrentWidow(Window window)
        {
            CurrentWindow = window;
        }

        /// <summary>
        /// 设置 当前用户
        /// </summary>
        /// <param name="currentLoginUser"></param>
        public static void SetCurrentUser(CurrentLoginUser currentLoginUser)
        {
            CurrentLoginUser = currentLoginUser;
        }
    }
}
